<?php
namespace app\admin\controller;

use think\Controller;
/**
 * 数据库备份控制器
 * Class Data
 * @package app\index\controller
 */
class Data extends Controller
{
    //数据库备份
    public function getBak(){
        $type=input("tp");
        $name=input("name");
        $sql=new \org\Baksql(\think\Config::get("database"));
        switch ($type)
        {
            case "backup": //备份
                $info = $sql->backup();
                echo $info;
                break;
            case "dowonload": //下载
                $info = $sql->downloadFile($name);
                $this->success("$info",'index/backup/bak');
                break;
            case "restore": //还原
                $info = $sql->restore($name);
                $this->success("$info",'index/backup/bak');
                break;
            case "del": //删除
                $info = $sql->delfilename($name);
                $this->success("$info",'index/backup/bak');
                break;
            default:
                return admin_json(1,'获取成功',["list"=>$sql->get_filelist()]);
        }
    }
}